package com.flying.ouyu.tool;

import android.widget.Toast;

import com.flying.ouyu.OuyuApplication;

public class ToastUtil {
	
	public static void showTimeLong(String msg)
	{
		show(msg,Toast.LENGTH_LONG);
	}
	
	public static void showTimeShort(String msg)
	{
		show(msg,Toast.LENGTH_SHORT);
	}
	
	public static void show(final String msg,final int duration)
	{
		if (OuyuApplication.getInstance().isInMainThread())
		{
			toastShow(msg,duration);
		}
		else
		{
			OuyuApplication.getInstance().getHandler().post(new Runnable(){
				public void run()
				{
					toastShow(msg,duration);
				}
			});
		}
	}
	
	private static void toastShow(String msg, int duration)
	{
		Toast.makeText(OuyuApplication.getInstance(),msg,duration).show();
	}
}
